package com.cogwheel.framework.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CMD5Hash {
	public static String CGetHash(String input)
	{
		try
		{
			MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
		    digest.update(input.getBytes());
		    byte messageDigest[] = digest.digest();
		    
		    // Create Hex String
		    StringBuffer hexString = new StringBuffer();
		    for (int i=0; i<messageDigest.length; i++)
		        hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
		    return hexString.toString();
		    
		} catch (NoSuchAlgorithmException e) { e.printStackTrace(); }
		return "";
	}

}
